﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WEB.Controller;
using WEB.Model.Entity.Accout;
using WEB.Exceptions;

namespace WEB
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string username = Username.Text;
            string passwd = Passwd.Text;

            LoginAction action = new LoginAction();
            Admin admin = null;
            try
            {
                admin = action.checkLogin(username, passwd);
                //Response.Write(admin.birthday);
                //Response.Write(admin.tel);
                //登陆用户信息
                Session["user"] = admin;
                //用户登陆标识
                Session["flag"] = 1;
                Response.Redirect("~/index.aspx");
            }
            catch (UserNotExistException ee)
            {
                msg.Text = ee.Message;
            }
            catch (PasswordNotCorrectException ee)
            {
                msg.Text = ee.Message;
            }
            catch (Exception ee)
            {
                msg.Text = ee.StackTrace;
            }
        }
    }
}